import { useEffect, useState } from "react"

function useScrollPosition() {
    const [scrollX, setScrollX] = useState()
    const [scrollY, setScrollY] = useState()

    useEffect(() => {
        function handleScroll() {
            console.log(window.scrollX, window.scrollY)
            setScrollX(window.scrollX)
            setScrollY(window.scrollY)
        }
        window.addEventListener("scroll", handleScroll)
        return () => {
            window.removeEventListener("scroll", handleScroll)
        }
    }, [])
    return [scrollX, scrollY]
}

export default useScrollPosition
